package com.citms.aif.model;

import com.citms.exception.CloudException;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import lombok.AllArgsConstructor;

@AllArgsConstructor
public class ExceptionModel extends CloudException {

    private Integer code;
    private String codeRemark;


    public static ExceptionModel convert(String json) {

        JsonObject returnData = new JsonParser().parse(json).getAsJsonObject();
        JsonPrimitive code = returnData.getAsJsonPrimitive("code");
        JsonPrimitive codeRemark = returnData.getAsJsonPrimitive("codeRemark");
        ExceptionModel e = new ExceptionModel(code.getAsInt(),codeRemark.getAsString());
        e.setRes(json);
        return  e;
    }
}
